}
static void
-gtk_list_box_real_add (GtkContainer *container,
- GtkWidget *child)
+gtk_list_box_add_row (GtkListBox *list_box,
+ GtkWidget *child,
+ gboolean prepend)
{
- GtkListBox *list_box = GTK_LIST_BOX (container);
GtkListBoxPrivate *priv = gtk_list_box_get_instance_private (list_box);
GtkListBoxRow *row;
GSequenceIter* iter = NULL;
if (priv->sort_func != NULL)
iter = g_sequence_insert_sorted (priv->children, row,
(GCompareDataFunc)do_sort, list_box);
+ else if (prepend)
+ iter = g_sequence_prepend (priv->children, row);
else
iter = g_sequence_append (priv->children, row);
-
ROW_PRIV (row)->iter = iter;
gtk_widget_set_parent (GTK_WIDGET (row), GTK_WIDGET (list_box));
gtk_widget_set_child_visible (GTK_WIDGET (row), TRUE);
}
}
+static void
+gtk_list_box_real_add (GtkContainer *container,
+ GtkWidget *child)
+{
+ gtk_list_box_add_row (GTK_LIST_BOX (container), child, FALSE);
+}
+
static void
gtk_list_box_real_remove (GtkContainer *container,
GtkWidget *child)
}
}
+/**
+ * gtk_list_box_prepend:
+ * @list_box: a #GtkListBox.
+ * @child: the #GtkWidget to add
+ *
+ * Prepend a widget to the list. If a sort function is set, the widget will
+ * actually be inserted at the calculated position and this function has the
+ * same effect of gtk_container_add().
+ *
+ * Since: 3.10
+ */
+void
+gtk_list_box_prepend (GtkListBox *list_box,
+ GtkWidget *child)
+{
+ gtk_list_box_add_row (list_box, child, TRUE);
+}
+
/**
* gtk_list_box_drag_unhighlight_row:
* @list_box: An #GtkListBox.